package com.ins.asyncrequest.hselect;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

//import org.apache.coyote.http11.Http11Nio2Protocol;

public class userlogin extends HttpServlet {

	private String usertype;
	private String user = "F";
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		response.setContentType("text/html");
		ServletContext sc = getServletContext();
		RequestDispatcher rd = null;
		HttpSession session=request.getSession();
		String usertype = (String)session.getAttribute("usertype");
		String inid = (String)session.getAttribute("inid");
		if(usertype!=null){
			if(usertype.equals("1")){
				session.setAttribute("inid", inid);
				session.setAttribute("1", usertype);//消费用户判断标识
				request.getRequestDispatcher("/WEB-INF/pages/userCenter3.jsp").forward(request,response);
				Writer writer = response.getWriter();
			}
			if(usertype.equals("2")){
				session.setAttribute("inid", inid);
				session.setAttribute("2", usertype);//仪器管理人员判断标识
				request.getRequestDispatcher("/WEB-INF/pages/yiqixinxiweihu15.jsp").forward(request,response);
				Writer writer = response.getWriter();
				
			}
			if(usertype.equals("3")){
				session.setAttribute("inid", inid);
				session.setAttribute("3", usertype);//机构判断标识
				request.getRequestDispatcher("/WEB-INF/pages/ins28.jsp").forward(request,response);
				Writer writer = response.getWriter();
				
			}
		}else{
			request.getRequestDispatcher("/login.jsp").forward(request,response);
		}

	}

}
